<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <jsp:include page="../inc.jsp"></jsp:include>
</head>
<body>
<table style="width:100%;height:80%;margin: 0;" id="aticle_datagrid"></table>
<script type="text/javascript">
    var data_datagrid;
    var datagrid_data_from;
    $(function(){
        data_datagrid = $('#aticle_datagrid').datagrid({
            url: "${pageContext.request.contextPath}/article/backPage",
            singleSelect: true,
            columns: [[
                {field: 'id', title: 'id', width: "10%"},
                {field: 'articleName', title: '名称', width: "30%"},
                {field: 'categoryId', title: '分类', width: "20%"},
                {field: 'labelId', title: '标签', width: "20%"},
                {field: 'usersId', title: '上传者', width: "10%"},
                {field: 'state', title: '状态', width: "10%"}
            ]],
            loadFilter: function (data) {
                console.info(JSON.stringify(data));
                data = data.data;
                console.info(data);
                return {"total": data.totalSize, "rows": data.data};
            },
            pagination:true
        });

        var pager = $('#aticle_datagrid').datagrid().datagrid('getPager');	// get the pager of datagrid
        pager.pagination({
            buttons:[{
                iconCls:'icon-add',
                handler:function(){
                    var index_tabs =  $('#index_tabs', window.parent.document);
                    console.info(index_tabs);
                    var tab = index_tabs.tabs('getSelected');
                    var index = index_tabs.tabs('getTabIndex',tab);
                    alert(index);
                    /* data_from = parent.$.modalDialog({
                         title: '添加文章',
                         width : 1000,
                         height : 730,
                         href: '${pageContext.request.contextPath}/article/add',
                        buttons: [{
                            text: '添加',
                            iconCls: 'icon-ok',
                            handler: function () {
                                parent.$.modalDialog.openner_dataGrid = dataGrid;
                                parent.window.submit_label_from();
                            }
                        }]
                    });*/
                }
            },{
                iconCls:'icon-cancel',
                handler:function(){
                    alert('cancel');
                }
            },{
                iconCls:'icon-edit',
                handler:function(){
                    alert('edit');
                }
            }]
        });
    })
</script>
</body>
</html>
